import request from '@/utils/request'
import { type loginByPhoneNumber, type loginByUserName, type registerUser, baseResponse, type userInfo, type userPermission, userMessage } from '@/types/index'

// 注册接口
export const userRegisterVoluntary = async (user: registerUser) =>
  (await request.post<baseResponse<string>>('VoluntaryIdentity/UserManager/CreateVolunteerUser', user)).data
// 注册接口
export const userRegisterOrganizer = async (user: registerUser) =>
  (await request.post<baseResponse<string>>('VoluntaryIdentity/UserManager/CreateOrganizerUser', user)).data

// 登录接口
export const userLoginByUserName = async (user: loginByUserName) =>
  (await request.post<baseResponse<string>>('VoluntaryIdentity/Login/LoginByUserName', user)).data
export const userLoginByUserPhone = async (user: loginByPhoneNumber) =>
  (await request.post<baseResponse<string>>('VoluntaryIdentity/Login/LoginByUserPhone', user)).data

// 获取用户信息接口
export const getUserInfo = async () => (await request.get<baseResponse<userInfo>>('VoluntaryIdentity/UserManager/GetUserInfo')).data
//获取用户权限接口
export const getUserPermission = async () => (await request.get<baseResponse<Array<userPermission>>>('VoluntaryIdentity/Permission/GetRolePermissions')).data

export const getUserMessageCount = async () => (await request.get<baseResponse<number>>('VoluntaryIdentity/UserManager/GetUserMessageCount')).data

export const getUserMessageList = async (activityId: number) =>
  (await request.get<baseResponse<Array<userMessage>>>(`VoluntaryIdentity/UserManager/GetActivityAllMessage?ActivityId=${activityId}`)).data
